using System.Collections.Generic;
using UnityEngine;
using System.Collections;

// projectile
public class Projectile : MonoBehaviour
{
    private float speed;
    private float lifeTime;
    private float timer;
    private Vector3 dir;

    public void Init(float speed, float lifeTime)
    {
        this.speed = speed;
        this.lifeTime = lifeTime;
        timer = 0;
    }

    void Update()
    {
        timer += Time.deltaTime;
        if (timer > lifeTime)
        {
            GameObject.Destroy(gameObject);
        }
        transform.position += dir * speed * Time.deltaTime;
    }

    public void SetDir(Vector3 dir)
    {
        this.dir = dir;
    }
}